/*****
 * 
 * 
 * *******新闻详情********
 * 
 * 
 * ******/
/************获取数据对象**********/
var getjudiciarydetaildata={
	title:'获取法律咨询详情页',
	url:'./json/judiciary.json',
    fromwho:'lj',
	sendData:{"id":1},
}
getAjax(getjudiciarydetaildata,
	function(data){
		setJudiciaryDetailData(data)
	},
	function(){
		mui.alert()
	}
)
//新闻渲染数据
function setJudiciaryDetailData(data){
	var contenDom='';
	var commentDom='';
	var data=data[0];
	var date=timeDate(data.date,true)
	console.log(data);
	//司法救助主体
	contenDom=`
		<p class="contentTitle">${data.title}</p>
		<p class="contentDateVisit">
			<span>${date}</span><span>浏览数:${data.scount}</span>
		</p>
		<div class="contentInfo">${data.content}</div>
	`
	$('.contentBox').append(contenDom)
	//司法救助评论
	$.each(data.commentList,(k,v)=>{
		var nowtime=timeBetween(v.date)
		commentDom+=`
			<li class="comOne">
				<p class="txName"><img src="${v.userhead}"><label>${v.username}</label></p>
				<p class="plnr">${v.content}</p>
				<p class="plsj">${nowtime}</p>
			</li>
		`
	});
	$('.comList ul').html(commentDom)
	//获取头像的高度，并赋值给名字,删除最后一条评论的下划线
	var picHeight = $(".txName img").width();
	$(".txName label").height(picHeight);
	$(".txName label").css("line-height",picHeight+"px");
	$(".comList ul li.comOne:last").css("border","0");
}
/************获取数据对象end**********/



/************页面跳转**********/
//打开评论页
mui(".footPl").on('tap','.xpl',function(){
	var id=GetQueryString('id')
	mui.openWindow({
		url:`comment.html?jid=${id}`,
	    id:'comment2.html',
	});
})
/************页面跳转end**********/


/************其他**********/
//呼出分享菜单
$('.fx').on('click', function(event){
    event.preventDefault();           
    $('.cd-popup').addClass('is-visible');
});
//关闭分享菜单
$('.cd-popup').on('click', function(event){
    if( $(event.target).is('.cd-popup-close') || $(event.target).is('.cd-popup') ) {
        event.preventDefault();
        $(this).removeClass('is-visible');
    }
});
/************其他end**********/




/******分享h5+******/
var Intent = null, 
    File = null, 
    Uri = null, 
    main = null; 
var shares = null; 
var shareImageUrl = ''; 
mui.plusReady(function() {   
    updateSerivces(); 
    if (plus.os.name == "Android") { 
        Intent = plus.android.importClass("android.content.Intent"); 
        File = plus.android.importClass("java.io.File"); 
        Uri = plus.android.importClass("android.net.Uri"); 
        main = plus.android.runtimeMainActivity(); 
    } 
}) 
// 更新分享服务 
function updateSerivces() { 
    plus.share.getServices(function(s) { 
        shares = {}; 
        for (var i in s) { 
            var t = s[i]; 
            shares[t.id] = t; 
        } 
        outSet("获取分享服务列表成功"); 
    }, function(e) { 
        outSet("获取分享服务列表失败：" + e.message); 
    }); 
} 
/** 
 * 分享操作 
 */ 
function shareAction(id, ex) { 
    var s = null; 
    if (!id || !(s = shares[id])) { 
        outLine("无效的分享服务！"); 
        return; 
    } 
    if (s.authenticated) { 
        outSet("---已授权---"); 
        shareMessage(s, ex); 
    } else { 
        outSet("---未授权---"); 
        s.authorize(function() { 
            shareMessage(s, ex); 
        }, function(e) { 
            outLine("认证授权失败"); 
        }); 
    } 
} 
//发送分享消息 
function shareMessage(s, ex) { 
	var url=window.location.href
    var msg = { 
        content: '分享-详情', 
        href: 'http://blog.csdn.net/zhuming3834', 
        title: 'HGDQ-分享测试-title', 
        content: 'HGDQ-分享测试-content', 
        thumbs: ['http://img3.3lian.com/2013/v10/4/87.jpg'], 
        pictures: ['http://img3.3lian.com/2013/v10/4/87.jpg'], 
        extra: { 
            scene: ex 
        } 
    }; 
    s.send(msg, function() { 
        outLine("分享成功!"); 
    }, function(e) { 
        outLine("分享失败!"); 
    }); 
} 
//点击分享
mui(".fxBox").on('tap','.fx-wx',function(){
	shareAction('weixin','WXSceneSession'); 
})
//分享到朋友圈
mui(".fxBox").on('tap','.fx-pyq',function(){
	shareAction('weixin', "WXSceneTimeline"); 
})
//分享到QQ
mui(".fxBox").on('tap','.fx-qq',function(){
	shareAction('qq'); 
})
mui(".fxBox").on('tap','.fx-wb',function(){
	shareAction('sinaweibo'); 
})

/******分享h5+****end**/